﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
</head>
<body>
    <div style=" padding-bottom: 15px">
        <h1>拖动Demo</h1>
        <table>
            <tr>
                <td>拖动图片</td>
                <td><img src="Dota2Log.png" /></td>
            </tr>
            <tr>
                <td>拖动文字</td>
                <td>hello word</td>
            </tr>
        </table>
    </div>
    <div style=" width: 300px ; height: 300px ; border:1px solid red " id="target"></div>

    <script type="text/javascript">
        window.onload = function () {
            document.addEventListener("dragover", function (event) {
                event.preventDefault();
            }, false)
            document.addEventListener("dragenter", function (event) {
                event.preventDefault();
            }, false)
            document.addEventListener("drop", function (event) {
                var dataTransfer = event.dataTransfer;
                if (dataTransfer.getData("url")) {
                    //拖动
                    window.open(dataTransfer.getData("url"));
                } else {
                    window.open("http://www.baidu.com");
                }
            }, false);
        }
    </script>
</body>
</html>
